/* 
 * 创建日期 2011-3-30
 *
 * 成都天和软件公司
 * 电话：028-85425861 
 * 传真：028-85425861-8008 
 * 邮编：610041 
 * 地址：成都市武侯区航空路6号丰德万瑞中心B座1001 
 * 版权所有
 */
package  org.fantasy.common.db.pool;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;


/**
 * 数据源
 * @author 王文成
 * @version 1.0
 * @since 2011-3-30
 */
public class OlapDataSource implements DataSource {
	
	private ConnectionManager manager;
	
	public OlapDataSource(ConnectionManager manager){
		this.manager = manager;
	}

	public int getLoginTimeout() throws SQLException {
    	throw new UnsupportedOperationException("getLoginTimeout");
    }

    public void setLoginTimeout(int timeout) throws SQLException {
        throw new UnsupportedOperationException("setLoginTimeout");
    }

    public PrintWriter getLogWriter() {
        throw new UnsupportedOperationException("getLogWriter");
    }

    public void setLogWriter(PrintWriter pw) throws SQLException {
        throw new UnsupportedOperationException("setLogWriter");
    }

    public Connection getConnection() throws SQLException {
    	DBOptions options = manager.getOptions();
    	Connection conn =  manager.getConnection(options.getTimeout());
    	return new OlapConnectionProxy(manager,conn);
    }

    public Connection getConnection(String username, String password) throws SQLException {
    	throw new UnsupportedOperationException("getConnection(String username, String password)");
    }

	public boolean isWrapperFor(Class<?> iface) throws SQLException {
		throw new UnsupportedOperationException("isWrapperFor");
	}

	public <T> T unwrap(Class<T> iface) throws SQLException {
		throw new UnsupportedOperationException("unwrap");
	}

}
